Skip to content

Conversation

@afshin-zafari
Copy link
Contributor

@afshin-zafari afshin-zafari commented Nov 5, 2025

In the test, page-numbers to be checked are passed to a checker function in which they will be changed to -1 if they are as expected.
Use of these -1 values for page-numbers in consequent checks result in overflow in pointer arithmetic of base + (-1) * page_size which is certainly less than base.

The fix is to skip cases where page-number under checking is -1.
Tested under UBSAN build.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8361487: [ubsan] test_committed_virtualmemory.cpp check_covered_pages shows overflow (Bug - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/28151/head:pull/28151
$ git checkout pull/28151

Update a local copy of the PR:
$ git checkout pull/28151
$ git pull https://git.openjdk.org/jdk.git pull/28151/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 28151

View PR using the GUI difftool:
$ git pr show -t 28151

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/28151.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Nov 5, 2025

👋 Welcome back azafari! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Nov 5, 2025

@afshin-zafari This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8361487: [ubsan] test_committed_virtualmemory.cpp check_covered_pages shows overflow

Reviewed-by: jsjolen, phubner

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 154 new commits pushed to the master branch:

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the hotspot-runtime hotspot-runtime-dev@openjdk.org label Nov 5, 2025
@openjdk
Copy link

openjdk bot commented Nov 5, 2025

@afshin-zafari The following label will be automatically applied to this pull request:

  • hotspot-runtime

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the rfr Pull request is ready for review label Nov 5, 2025
@mlbridge
Copy link

mlbridge bot commented Nov 5, 2025

Webrevs

Comment on lines 86 to 88
static constexpr int PAGE_CONTAINED_IN_RANGE_TAG = -1;
static constexpr bool IS_PAGE_CONTAINED_IN_COMMITTED_REGION(int a) { return (a == PAGE_CONTAINED_IN_RANGE_TAG); }
static constexpr void SET_PAGE_AS_CONTAINED_IN_COMMITTED_REGION(int &a) { a = PAGE_CONTAINED_IN_RANGE_TAG; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The functions aren't constexpr, so you can skip those. I think all of these can be in this_style_of_naming instead.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Nov 13, 2025
@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Nov 13, 2025
@openjdk openjdk bot added the ready Pull request is ready to be integrated label Nov 14, 2025
if (is_page_in_committed_region(page_num[index])) { // Already tagged?
continue;
}
address page_addr = base + page_num[index] * page_sz;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if we assert(page_num[index] >= 0) at this point if we know that negative numbers may cause overflows?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Negative numbers are not bug/invalid. They are used as a marker that the page is inside a committed region.
In the test we list/iterate all committed regions of a reserved memory are. For each committed region we check a list of pages whether the page is inside the committed region or not. if yes, we mark the page with -1. There two loops here one for committed regions and for list of page numbers.
After loops, we check and expect that all the pages were marked as being inside committed regions.

Copy link
Member

@Arraying Arraying left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this.

@afshin-zafari
Copy link
Contributor Author

Thank you @jdksjolen and @Arraying for your reviews.
/integrate

@openjdk
Copy link

openjdk bot commented Nov 14, 2025

Going to push as commit 9eaa364.
Since your change was applied there have been 154 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Nov 14, 2025
@openjdk openjdk bot closed this Nov 14, 2025
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Nov 14, 2025
@openjdk
Copy link

openjdk bot commented Nov 14, 2025

@afshin-zafari Pushed as commit 9eaa364.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hotspot-runtime hotspot-runtime-dev@openjdk.org integrated Pull request has been integrated

Development

Successfully merging this pull request may close these issues.

3 participants